package com.xteam.xnetworkdisk.config;

import com.xteam.xnetworkdisk.filter.SessionValidationFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean(name = "customSessionValidationFilter")
    public FilterRegistrationBean<SessionValidationFilter> sessionValidationFilter() {
        FilterRegistrationBean<SessionValidationFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new SessionValidationFilter());
        registrationBean.addUrlPatterns("/sys/*"); // Apply filter to protected URLs
        return registrationBean;
    }

//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/videos/**")
//                .addResourceLocations("file:/C:/Users/xiaoz/xnetworkdisk/file/xnetworkdisk/");
//    }

}
